package com.ymatou.iapi.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.liveseller.parameter.GetFutureLiveCountBean;
import com.ymatou.iapi.liveseller.service.GetFutureLiveCountCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.YMTDateUtil;
/**
*获取买手即将开始直播数
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetFutureLiveCount{
	private static GetFutureLiveCountBean getfuturelivecountBean;
	private static GetFutureLiveCountCall getfuturelivecountCall;
	private static LiveRoomWapper liveRoomWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买手即将开始直播数");
	}

	@Before
	public void caseUp() {
		getfuturelivecountBean=new GetFutureLiveCountBean();
		getfuturelivecountCall=new GetFutureLiveCountCall();
		liveRoomWapper=new LiveRoomWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getfuturelivecountCall.getOpurl());
		liveRoomWapper=null;
	}

	@After
	public void caseDown() {
		
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetFutureLiveCount_001() {
		Logger.start(true,"获取买手即将开始直播数成功");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(1, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetFutureLiveCount_002() {
		Logger.start(true,"输入不存在userid返回0");
		try {
			getfuturelivecountBean.setUserId(1);
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetFutureLiveCount_003() {
		Logger.start(true,"直播关闭status7获取买手即将开始直播数成功,不计算");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetFutureLiveCount_004() {
		Logger.start(true,"直播关闭status8获取买手即将开始直播数成功,不计算");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 8);
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetFutureLiveCount_005() {
		Logger.start(true,"直播关闭status9获取买手即将开始直播数成功,不计算");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 9);
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetFutureLiveCount_006() {
		Logger.start(true,"直播关闭status10获取买手即将开始直播数成功,不计算");
		try {
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			liveRoomWapper.updateLiveRoomPushStatus(createlive.getId(), 10);
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetFutureLiveCount_007() {
		Logger.start(true,"直播待开始status1获取买手即将开始直播数成功,不计算");
		try {
			//待开始status0 开始时间早于当前
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(null));
			LiveRoomCallService.UpdateLiveTimeToStart(createlive.getId());
			getfuturelivecountBean.setUserId(createlive.getUserId());
			getfuturelivecountCall.setData(getfuturelivecountBean);
			getfuturelivecountCall.callService();			
			int count=getfuturelivecountCall.getJsonObject().get("Data").getAsJsonObject().get("LiveCount").getAsInt();
			Logger.verifyEquals("200", getfuturelivecountCall.getString("Code"), "验证Code");
			Logger.verifyEquals(0, count, "验证count");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}